package com.hspedu.innerclass;

public class StaticInnerClass01 {
    public static void main(String[] args) {
        Outer10 outer10 = new Outer10();
        outer10.m1();

        //外部其他类 访问 静态内部类
        //方法一
        Outer10.Inner10 inner10 = new Outer10.Inner10();
        inner10.say();

        //方法二
        Outer10.Inner10 inner101 = outer10.getInner10();
        inner101.say();

        Outer10.Inner10 inner102 = Outer10.getInner10_();
        inner102.say();
    }
}


class Outer10 {//外部类
    private int n1 = 10;
    private static String name = "张三";

    //静态内部类
    //放在外部类成员位置
    //可以直接访问外部类的所有静态成员，但不能访问非静态成员
    static class Inner10 {
        public void say() {
            System.out.println(name);
        }

        public void show() {
            new Inner10().say();
        }
    }

    public void m1() {
        Inner10 inner10 = new Inner10();
        inner10.say();
    }

    public Inner10 getInner10() {
        return new Inner10();
    }

    public static Inner10 getInner10_() {
        return new Inner10();
    }
}